<?xml version="1.0" encoding="UTF-8"?>

<project name="poc" default="release" xmlns:artifact="urn:maven-artifact-ant">

	<tstamp>
		<format property="datestamp" pattern="yyyy-MM-dd_hh-mm-ss" />
	</tstamp>

	<property name="project.name" value="poc" />
	<property name="project.author" value="ffcs-mss" />
	<property name="project.version" value="1.0" />


	<property name="web.dir" value="WebContent" />
	<property name="web-inf.dir" value="${web.dir}/WEB-INF" />
	<property name="build.dir" value="${web.dir}/WEB-INF/classes" />
	
	<property name="doc.dir" value="doc" />
	
	<!-- package -->
	<property name="dist.dir" value="build/war" />	
	<property name="dist.war" value="${dist.dir}/${project.name}.war" />
	<property name="dist.testwar" value="${dist.dir}/beta/${project.name}.war" />
	<property name="release.runtime" value="${dist.dir}/release" />	
	<property name="release.test" value="${dist.dir}/beta" />	
	
	<property name="src.dir" value="src" />
	<property name="src-config.dir" value="${src.dir}/config_file/runtime" />
	<property name="src-config.testdir" value="${src.dir}/config_file/test" />

	<path id="compile.classpath">
		<fileset dir="${web.dir}/WEB-INF/lib" includes="**/*.jar" />
	</path>

	<!-- 正式发布版本 -->
	<target name="release">
		<fileset id="releaseSrc" dir="${web.dir}" />
			
		<delete dir="${release.runtime}" />
		<mkdir dir="${release.runtime}" />
		<copy todir="${release.runtime}" >
			<fileset refid="releaseSrc" />
		</copy>
		<!-- 更新正式环境包 -->
		<copy todir="${release.runtime}/WEB-INF/lib" overwrite="true">
			<fileset dir="build/dependency/runtime" />
		</copy>
		<!-- 更新正式环境配置文件 -->
		<copy todir="${release.runtime}/WEB-INF/classes" overwrite="true">
			<fileset dir="${src-config.dir}" />
		</copy>
		<!-- 删除不必要目录 -->
		<delete dir="${release.runtime}/runtime" />
		<delete dir="${release.runtime}/test" />
		<!-- 更新正式环境jsp文件 -->
		<copy todir="${release.runtime}" overwrite="true">
			<fileset dir="${web.dir}/runtime" />
		</copy>

		<!-- war -->
		<delete file="${dist.war}" />
		<war destfile="${dist.war}" basedir="${release.runtime}">
			<manifest>
				<section name="Shared">
					<attribute name="Version" value="${project.version}"/>
					<attribute name="Date" value="${datestamp}"/>
				</section>
				<section name="Copyright">
					<attribute name="Copy" value="(C) ${project.id} 2009"/>
				</section>
			</manifest>
		</war>

		<delete dir="${release.runtime}" />
		
	</target>
	
	<!-- 测试环境发布版本 -->
		<target name="release_test">
			<fileset id="releaseSrc" dir="${web.dir}" />
				
			<delete dir="${release.test}" />
			<mkdir dir="${release.test}" />
			<copy todir="${release.test}" >
				<fileset refid="releaseSrc" />
			</copy>
			<!-- 更新正式环境包 -->
			<copy todir="${release.test}/WEB-INF/lib" overwrite="true">
				<fileset dir="build/dependency/runtime" />
			</copy>
			<!-- 更新正式环境配置文件 -->
			<copy todir="${release.test}/WEB-INF/classes" overwrite="true">
				<fileset dir="${src-config.testdir}" />
			</copy>
			<!-- 删除不必要目录 -->
			<delete dir="${release.test}/runtime" />
			<delete dir="${release.test}/test" />
			<!-- 更新正式环境jsp文件 -->
			<copy todir="${release.test}" overwrite="true">
				<fileset dir="${web.dir}/test" />
			</copy>

			<!-- war -->
			<delete file="${dist.testwar}" />
			<war destfile="${dist.testwar}" basedir="${release.test}">
				<manifest>
					<section name="Shared">
						<attribute name="Version" value="${project.version}"/>
						<attribute name="Date" value="${datestamp}"/>
					</section>
					<section name="Copyright">
						<attribute name="Copy" value="(C) ${project.id} 2009"/>
					</section>
				</manifest>
			</war>

			<delete dir="${release.test}" />
			
		</target>
</project>